package com.lf.api.service.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lf.api.po.dao.SubjectMapper;
import com.lf.api.po.domain.Subject;
import com.lf.api.service.SubjectService;

/**
 * 
 * Description: 主题类
 * Copyright: Copyright (c)2012
 * Company: 小小书童
 * @author: 小小书童
 * @version: 1.0
 * Create at: 2016年9月27日 上午12:40:13
 *
 * Modification History:
 * Date Author Version Description
 * ---------------------------修改历史---------------------------------------
 * 2016年9月27日 小小书童 1.0
 */
@Service
public class SubjectServiceImpl implements SubjectService {

	@Autowired
	SubjectMapper subjectMapper;
	
	@Override
	public List<Subject> listSubject(Map<String, Object> param) {
		return subjectMapper.selectByPage(param);
	}

	@Override
	public void insertSubject(Subject subject) {
		subject.setBuyNum(0);
		subject.setCharge(subject.getPrice().floatValue() == 0 ? (short)0 : 1);
		subject.setCreateTime(new Date());
		subject.setFavoriteNum(0);
		subject.setGreateNum(0);;
		subject.setState((short)0);
		subject.setViewNum(0);
		subjectMapper.insert(subject);
	}

	@Override
	public Subject getSubjectById(Long id) {
		return subjectMapper.selectByPrimaryKey(id);
	}

	

}
